package com.xyd.Service;

import com.xyd.bean.ChildCategory;
import com.xyd.dao.ChildCategoryMapper;
import com.xyd.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class ChildService {
    SqlSession sqlSession = SqlSessionFactoryUtil.getSqlSession();
    ChildCategoryMapper childCategoryMapper = sqlSession.getMapper(ChildCategoryMapper.class);

    public List<ChildCategory> getChildByPId(int parentid){
        return childCategoryMapper.getChildByPId(parentid);
    }
    //根据id获取详情
    public ChildCategory getById(int id){
        return childCategoryMapper.getByChildid(id);
    }
    //根据id修改
    public int modifyChild(ChildCategory childCategory ){
        return childCategoryMapper.updateById(childCategory);
    }
    //根据id删除
    public int delChild(int id){
        return childCategoryMapper.delByChildid(id);
    }

    public List<ChildCategory> getAllChild(){
        return childCategoryMapper.getAllChild();
    }
    public int addChild(ChildCategory childCategory){
        return childCategoryMapper.insertAll(childCategory);
    }
}
